public class question_38 {
}
class Solution_38 {
//    写一个递归的函数
    public String recursion(String last,int n,int target){
        String result="";
        char[] arr = last.toCharArray();
        int sum=1;
        for (int i = 0; i < arr.length; i++) {
            if(i==arr.length-1){
                result=result+(sum+""+arr[i]);
                break;
            }
            if(arr[i]==arr[i+1]){
                sum++;
                continue;
            }else{
                result=result+(sum+""+arr[i]);
                sum=1;
            }
        }
        return target==n?result:recursion(result,n+1,target);
    }
    public String countAndSay(int n) {
        if(n==1){
            return "1";
        }else {
            return recursion("1",2,n);
        }
    }
}
